<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: show.phtml 5174 2010-08-30 10:57:01Z huuphuoc $
 * @since		2.0.0
 */
?>
<?php 
	$heightDefine = 150; 
?>
<style>
	.viewImageABC{
		overflow: hidden;
		width	: 300px;
		height	: <?php echo $heightDefine?>px;
	}
</style>
<?php 
	for($i=0;$i<count($this->articles);$i++):
?>
	<div class="grid_4 alpha t_space_bottom" style="margin-bottom:10px;">
		<div class="viewImageABC">
			<?php 
					$file = $this->articles[$i]->image_medium;
					$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);					
					$file = Tomato_Helper_Helper::checkFile($path, $file, '_medium');
					$urlImage = $file ? $file : $this->baseUrl().'/skins/bizprofile/default/html/images/img.jpg';
					$top  = 0;
					$left = 0;
					
					if($file){
						$res = getimagesize($path);
						$width   = $res[0];						
						$height  = $res[1];
					}else{
						$path = str_replace($this->APP_STATIC_SERVER,getcwd(),$urlImage);
						$res  = getimagesize($path);
						$width   = $res[0];						
						$height  = $res[1];
					}					
					$height = floor((300 * $height)/$width); 
					if($height > $heightDefine)
						$top = floor(($height - $heightDefine)/2)* (-1);						
						
					$style=' style="position:relative;top:'.$top.'px;width:300px;" ';
			?>
			<a href="<?php echo $this->url($this->articles[$i]->getProperties(), 'news_article_details'); ?>">								
				<img <?php echo $style;?> id="img_<?php echo $i;?>" src="<?php echo $urlImage;?>"/>
			</a>
		</div>
		<h2><a href="<?php echo $this->url($this->articles[$i]->getProperties(), 'news_article_details'); ?>"><?php echo strip_tags($this->articles[$i]->title); ?></a></h2>
		<span><?php echo strip_tags($this->articles[$i]->description); ?></span>			
	</div>
	<?php if($i>0 && $i%2==1):?>
		<div class="grid_8 t_a_bottom"> &nbsp; </div>
	<?php endif;?>
<?php endfor;?>